﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>新增在线咨询</title>

    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />

    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/avalon.mobile.min.js"></script>
    <script src="../JS/MobileCom.js?v=1.2"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="../JS/jquery.autoTextarea.js"></script>
    <script>
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            //隐藏右上角按钮
            WeixinJSBridge.call('hideOptionMenu');
        });

        //MobileCom.delCookie("szhlcode");
        //if (MobileCom.getCookie("szhlcode") == null) {
        //    MobileCom.setCookie("szhlcode", "90d62be9-4dd7-4dc9-9466-4e75042f25a0", 7);
        //}
        var strType = MobileCom.getQueryString("Type");
        var width = 0;
        var model = avalon.define({
            $id: "zxmodel",
            wximg:"",
            ctData: { "Type": "", "Title": "", "Description": "", "Status": "0", "ZXUser": "", "intProcessStanceid": "0", "Files": "" },
            savedata: function () {
                if (!model.ctData.Title) {
                    $.tips({
                        content: "请输入标题",
                        stayTime: 2000,
                        type: "warn"
                    })
                    return;
                }

                var lg = $.loading({
                    content: '保存中...',
                })

                $("#imglist .tpli").each(function () {
                    if ($(this).hasClass("wximg")) { //微信上传未处理的图片
                        if (model.wximg) {
                            model.wximg += ",";
                        }
                        model.wximg += $(this).attr("itemid");

                    } else {
                        if (model.ctData.Files) {
                            model.ctData.Files = model.ctData.Files + ',' + $(this).attr("itemid");
                        }
                        else {
                            model.ctData.Files = $(this).attr("itemid");
                        }
                    }

                })

                $.post("/API/WXAPI.ashx?Action=ADDZXZX&r=" + Math.random(), { "P1": JSON.stringify(model.ctData.$model), "P2": model.wximg }, function (data) {
                    lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $("button").hide();
                        var el = $.tips({
                            content: "保存成功！！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            window.location.reload();
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            },
            bjk: function () {

                var tc = layer.open({
                    type: 1,
                    //content:$("#bmxx").html(),
                    //title: "活动简介",
                    content: '<div class="ui-form-item ui-form-item-textarea ui-border-b" style="width:' + (width - 76) + 'px;height:200px"><textarea id="hdjjbjk" style="padding-left: 0;height:170px;border: 1px solid #e0e0e0;" placeholder="请输入详细内容">' + model.ctData.Description + '</textarea></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {
                        model.ctData.Description = $("#hdjjbjk").val();
                        if ($("#hdjjbjk").val() != "") {
                            $("#hdjj").removeClass("ui-txt-muted");
                            $("#hdjj").html($("#hdjjbjk").val());
                        }
                        else {
                            $("#hdjj").addClass("ui-txt-muted");
                            $("#hdjj").html("请输入详细内容");
                        }

                        layer.close(tc);

                    }, no: function () {
                    }
                })
                $("#hdjjbjk").focus();
            }

        });

        avalon.ready(function () {
            width = document.documentElement.clientWidth;
            if (strType) {
                model.ctData.Type = strType;
                $('input').eq(1).focus();
            }
            else {
                $('input').eq(0).focus();
            }
            //var lg = $.loading({
            //    content: '加载中...',
            //})
            //$.post("/API/WXAPI.ashx?Action=GETCOLUMNLIST&r=" + Math.random(), { "P1": "13" }, function (data) {
            //    lg.hide();
            //    var data = $.parseJSON(data);
            //    if (data.ErrorMsg == "") {
            //        $("select").empty();
            //        for (var i = 0; i < data.Result.length; i++) {
            //            $("select").append('<option value="' + data.Result[i].TypeNO + '">' + data.Result[i].TypeNO + '</option>');
            //            if (i == 0) {
            //                model.ctData.Type = data.Result[i].TypeNO;
            //            }
            //        }
            //    }
            //})

            MobileCom.uploadimg();
            $(".chackTextarea-area").autoTextarea({
                maxHeight: 220,
                minHeight: 80
            });
        })

        function back() {
            window.location.replace("UI_ZXZX_XMLIST.html?r=" + Math.random());
        }
    </script>
    <style type="text/css">

        .ms-controller, [ms-controller] {
            display: none;
        }
        .ui-form-item .wspan {
            width: 100%;
            display: -webkit-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            padding-left: 95px;
        }

            .ui-form-item .wspan img {
                width: 50px;
                height: 50px;
                padding-right: 3px;
            }

        .sctp {
            color: #18b4ed;
            right: 4px;
            top: -5px;
            z-index: 9;
            width: 20px;
            height: 20px;
            background: #fff;
            border-radius: 13px;
            line-height: 20px;
            text-indent: -3px;
            position: absolute;
            font-size: 25px;
        }

        .imgxl {
            position: relative;
            float: left;
            padding-top: 0;
            height: 50px;
            width: 50px;
            padding-right: 10px;
            margin-left: 0px;
            margin-bottom: 5px;
        }

        .tpxs {
            height: 50px;
            width: 50px;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
            background-repeat: no-repeat;
            -webkit-background-size: cover;
        }
    </style>
</head>
<body ms-controller="zxmodel">
    <div id="content">

        <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
            <button class="ui-btn-lg" onclick="back()">
                取消
            </button>
            <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()" id="save">
                在线咨询
            </button>
        </div>
        <section class="ui-container">
            <div class="ui-form ui-border-t">
                <div class="ui-form-item ui-border-b ">
                    <label>
                        项目名称
                    </label>
                    <!--<div class="ui-select ui-border-b">
                        <select ms-duplex="ctData.Type"></select>
                    </div>-->
                    <input type="text" placeholder="请输入项目名称" ms-duplex="ctData.Type" />
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        标题
                    </label>
                    <input type="text" placeholder="请输入标题" ms-duplex="ctData.Title" />
                </div>
                <div class="ui-form-item ui-border-b ui-form-item-textarea" style="height:auto;min-height:44px">
                    <label>
                        详细内容
                    </label>
                    <textarea placeholder="请输入详细内容" style="height:80px;" class="chackTextarea-area" ms-duplex="ctData.Description"></textarea>
                    <!--<div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="hdjj" ms-click="bjk()">请输入详细内容</div>-->
                    <!--<textarea placeholder="请输入详细内容" ms-duplex="ctData.Description"></textarea>-->
                    <!--<textarea rows=5 cols=40 placeholder="请输入详细内容" ms-duplex="ctData.Description" style="overflow:scroll;overflow-y:hidden;overflow-x:hidden;margin-top:13px"
                  onfocus="window.activeobj=this;this.clock=setInterval(function(){activeobj.style.height=activeobj.scrollHeight+'px';},200);" onblur="clearInterval(this.clock);"></textarea>-->
                    <!--<textarea rows=5 placeholder="请输入详细内容"  ms-duplex="ctData.Description" style="overflow:scroll;overflow-y:hidden;overflow-x:hidden;margin-top:13px"
                  onpropertychange="this.style.height = this.scrollHeight + 'px'" onload="    this.style.height = this.scrollHeight + 'px'" oninput="    this.style.height = this.scrollHeight + 'px'"></textarea>-->
                </div>
                <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                    <label>
                        上传照片
                    </label>

                    <div class="wspan" style="padding-top: 5px; height: auto;display:block">
                        <ul id="imglist">
                            <li class="imgxl scli"><img id="add_pit" src="../Images/icon-add.png" /></li>
                        </ul>
                        <div style="clear:both"></div>
                    </div>
                </div>

            </div>
        </section>
    </div>

</body>

</html>

